package close.mazegame.tile;

import close.mazegame.collision.Collidable;
import close.mazegame.entity.PhysicsEntity.EntityCategory;

import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
import com.badlogic.gdx.physics.box2d.World;

public abstract class SolidTile extends Tile implements Collidable {
	
	Body body;
	
	public SolidTile(Vector2 pos, World world){
		super();
		BodyDef bodyDef = new BodyDef();
		bodyDef.type = BodyType.StaticBody;
		bodyDef.position.set(pos);  
		body = world.createBody(bodyDef);

		PolygonShape box = new PolygonShape();
		box.setAsBox(SIZE/2, SIZE/2);
		FixtureDef fixtureDef = new FixtureDef();
		fixtureDef.filter.categoryBits = EntityCategory.SOLIDTILE.getBits();
		fixtureDef.shape = box;
		fixtureDef.density = 1.0f;
		body.createFixture(fixtureDef);
		box.dispose();
		
		body.setUserData(this);
	}

	@Override
	public Vector2 getPosition() {
		return body.getPosition();
	}

	@Override
	public boolean isSolid() {
		return true;
	}
	
	public void startContact(Collidable other){
	}
	
	public void endContact(Collidable other){
	}
	
	public boolean isRemoved() {
		return false;
	}
	
	public float getDamageMod(){
		return 0;
	}
	
	public float getMass(){
		return body.getMass();
	}
	
	public Vector2 getVelocity(){
		return body.getLinearVelocity();
	}

}
